<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
      var jsonstr = '{"name":"tom","age":18,"gender":"male","address": ["beijing","xian","shanghai"]}';
        //jsonstr是在字符串,而不是属性,不能用.调用
        //alert(jsonstr.name);

        var obj = JSON.parse(jsonstr);
        alert(obj.name);

        alert(JSON.stringify(obj));
    </script>

</body>

</html>